package com.maduar.batch.demo.credit;

import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.core.ItemReadListener;
import org.springframework.batch.core.SkipListener;
import org.springframework.batch.item.file.FlatFileParseException;

/**
 * Description:
 *
 * @Author maduar maduar@163.com
 * @Date 2021-07-16 22:49
 */
@Slf4j
public class CreditListener implements ItemReadListener<CreditBill> {

    private int count;

    @Override
    public void beforeRead() {

    }

    @Override
    public void afterRead(CreditBill creditBill) {

    }

    /**
     *  @Author: maduar maduar@163.com
     *  @Date: 2021-07-21 22:51
     *  @Discription:   exec read error
     *
     */
    @Override
    public void onReadError(Exception e) {
        log.info("input: " + ((FlatFileParseException) e).getInput());
        log.info("read-error: " + (++count));
    }
}
